package com.benshou.bsoa.controller.xinchou;

import com.benshou.bsoa.common.dto.ResponseVo;
import com.benshou.bsoa.dto.renshi.req.EmployeeDataRequest;
import com.benshou.bsoa.dto.renshi.res.EmployeeDataResponse;
import com.benshou.bsoa.dto.xinchou.req.SalaryAccountRequest;
import com.benshou.bsoa.dto.xinchou.req.SalaryArchiveRequest;
import com.benshou.bsoa.dto.xinchou.res.SalaryAccountResponse;
import com.benshou.bsoa.dto.xinchou.res.SalaryArchiveResponse;
import com.benshou.bsoa.service.dingding.EmployeeDataService;
import com.benshou.bsoa.service.dingding.SalaryArchiveService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/salary-archives")
public class SalaryArchiveController {

    @Autowired
    private SalaryArchiveService salaryArchiveService;

    @Autowired
    private EmployeeDataService employeeDataService;

    public SalaryArchiveController(SalaryArchiveService salaryArchiveService) {
        this.salaryArchiveService = salaryArchiveService;
    }

    /**
     * 查询薪资档案数据
     * @param salaryArchiveRequest 请求参数
     * @return 响应对象，包含薪资档案数据
     */
    @PostMapping("/get")
    public ResponseVo<SalaryArchiveResponse> getSalaryArchives(@RequestBody @Valid  SalaryArchiveRequest salaryArchiveRequest) throws Exception {
        return ResponseVo.success(salaryArchiveService.fetchSalaryArchives(salaryArchiveRequest));
    }

    /**
     * 查询员工信息
     * @param employeeDataRequest 请求参数
     * @return 响应对象，包含员工信息
     */
    @PostMapping("/getEmployeeData")
    public ResponseVo<EmployeeDataResponse> getEmployeeData(@RequestBody @Valid  EmployeeDataRequest employeeDataRequest) throws Exception {
        return ResponseVo.success(employeeDataService.fetchEmployeeData(employeeDataRequest));
    }

    /**
     * 工资结算
     * @param request 请求参数
     * @return 响应对象，包含薪资档案数据
     */
    @PostMapping("/salaryAccount")
    public ResponseVo<SalaryAccountResponse> getSalaryAccount(@RequestBody SalaryAccountRequest request) throws Exception {
        return ResponseVo.success(salaryArchiveService.fetchSalaryAccount(request));
    }
}